﻿#include "CPageScene.h"

CPageScene::CPageScene(const QString & name, CBaseScene * parent)
	:CBaseScene(name,parent)
{
	m_eSceneType = enPageScene;
	m_pItem->setFlags(m_pItem->flags() |Qt::ItemIsDragEnabled);
	((CBaseScene *)parent)->addChild(this);
	m_pItem->setData(m_sName, Qt::UserRole + 2);
	m_pItem->setIcon(QIcon(":/SmartControl/Resource/file.png"));

}

CPageScene::~CPageScene()
{
}

void CPageScene::addItem(SPageItem item)
{
	m_vecPageItem.push_back(item);
	setItemData();
}

QVector<SPageItem> CPageScene::getPageItems()
{
	return m_vecPageItem;
}

/********************************************************************************
*Description:  保存页面里面的卡片
*FunParameter:
*FunReturnValue:
*Author:Gaojia
*Date:2025/06/25
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
void CPageScene::setPageItems(QVector<SPageItem> vecPageItems)
{
	m_vecPageItem = vecPageItems;
	setItemData();
}

void CPageScene::setItemData()
{
	m_pItem->setData(QVariant(), Qt::UserRole + 1);
	QVariantList deviceList;
	for (int i = 0; i < m_vecPageItem.size(); i++)
	{
		deviceList << QVariant::fromValue(m_vecPageItem[i]);
	}
	// 设置数据
	m_pItem->setData(deviceList, Qt::UserRole+1);
}
